/*
 * auth.h
 *
 *  Created on: Dec 13, 2013
 *      Author: killerg
 */

#ifndef AUTH_H_
#define AUTH_H_


#include "share/util.h"
#define SHMPATH "/auth_log"
#define LOGNUM 500
#define LOGITEMLEN 400
struct mem_t {
	struct logitem_t {
		time_t time;
		char text[LOGITEMLEN];
	};

	time_t create_ts;
	uint32_t pid;
	int32_t cur_idx;
	logitem_t logs[LOGNUM];
};

int mem_log(const char* fmt, ...);

struct auth_cfg_t;
struct my_clock_t;
struct auth_mgr_t;
struct net_s;
struct tran_s;
struct logonsess_mgr_t;
struct auth_console_t;
struct db_mgr_t;
struct SvcData;

struct auth_t {
    auth_cfg_t* cfg;
    my_clock_t* clock;
    auth_mgr_t* authmgr;
    logonsess_mgr_t* logonsess_mgr;
    auth_console_t* console;
    db_mgr_t* db_log;
    mem_t* mem;
    SvcData* svcdata;

    bool init(SvcData* svcdata_);
    void destroy();
    void update();

    double cpu_time = 0.0f;
};



extern auth_t g_auth;

#define g_console g_auth.console
#define g_cfg g_auth.cfg
#define g_clock g_auth.clock


#endif /* AUTH_H_ */
